<template>
    <div style="height: 100%;">
        <van-row class="search-row">
            <van-search v-model="formData.loucName" maxlength="20" show-action placeholder="楼层名称：" @search="onRefresh">
                <template #action>
                    <div @click="onRefresh">搜索</div>
                </template>
            </van-search>
        </van-row>
        <!-- 办公用品列表 -->
        <van-row class="listCon">
            <van-pull-refresh class="pullRefresh" v-model="refreshLoading" @refresh="onRefresh">
                <van-list v-model="loading" :finished="finished" :finished-text="listData.length ? '没有更多了' : ''"
                    @load="onLoad">
                    <van-swipe-cell v-for="val in listData" :key="val.index">
                        <div class="cellContent" @click="seletFloor(val)">
                            <div class="top">
                                <div class="flexTit">
                                    <!-- <p class="title">{{ val.NAME }}</p> -->
                                    <p class="other">
                                        <span class="status" :class="'status' + val.SHENQZT">{{ val.sqztStatusName }}</span>
                                    </p>
                                </div>
                                <div>
                                    <p>
                                        <span class="label">楼宇：</span>
                                        {{ val.FANGCNAME || "-" }}
                                    </p>
                                    <p>
                                        <span class="label">楼层：</span>
                                        {{ val.NAME || "-" }}
                                    </p>
                                    <p>
                                        <span class="label">楼层描述：</span>
                                        {{ val.LCMS || "-" }}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </van-swipe-cell>
                </van-list>
                <van-empty v-if="!loading && !listData.length" class="custom-image"
                    :image="require('../../../assets/images/empty.png')" description="暂无数据" />
            </van-pull-refresh>
        </van-row>
        <full-loading v-if="loading"></full-loading>
    </div>
</template>
<script>
import { queryLcWin } from "@/api/srvAssurance/assetLabel/assetLabel";
export default {
    data() {
        return {
            formData: {
                loucName: '',
                louyxx:'',
                pageIndex: 1,
                pageSize: 20
            },
            louyid:'',
            finished: false,
            refreshLoading: false,
            listData: [], // 列表数据
            loading: false,
            selectList: [],
        };
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
    },
    methods: {
        onRefresh() {
            this.refreshLoading = false;
            this.finished = false;
            this.listData = [];
            this.formData.pageIndex = 1;
            this.formData.louyxx=this.louyid
            this.getSearch();
        },
        onLoad() {
            this.formData.pageIndex++;
            this.getSearch();
        },
        // 获取表格数据
        getSearch() {
            this.loading = true;
            queryLcWin(this.formData).then((res) => {
                this.loading = false;
                if (res.data.length > 0) {
                    this.listData = [...this.listData, ...res.data];
                    if (this.listData.length >= res.totalCount) {
                        this.finished = true;
                    }
                } else {
                    this.finished = true;
                }
            }).catch(() => {
                this.loading = false;
                this.finished = true;
            });
        },
        seletFloor(val) {
            this.$emit("chooseFloor",val);
            this.$emit("close");
            this.resetForm()
        },
        // 重置表单
        resetForm() {
            this.formData = {
                loucName: '',
                louyxx:'',
                pageIndex: 1,
                pageSize: 20
            };
            this.listData=[];
            this.getSearch();
        },
    },
};
</script>

<style scoped lang="less">
.listCon {
    height: calc(100% - 50px);

    .cellContent {
        padding: 10px;

        .flex {
            display: flex;

            p:nth-of-type(1) {
                flex: inherit !important;
                width: 45%;
            }
        }
    }

    .redSpan {
        color: red;
    }
}
</style>
